package com.sailing.lianxi.task;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 * timer定时器测试
 * @author Administrator
 *
 */
public class TimerDemoTest {

	private int seconds;
	public TimerDemoTest(int seconds) {
		this.seconds = seconds;
	}
	
	/**
	 * timer 是定时器，
	 * timerTask 是定时器执行的任务 相当于定时炸弹
	 * 
	 */
	public void t1() {
		new Timer().schedule(new TimerTask() {
			public void run() {
				// TODO Auto-generated method stub
			System.out.println("bombing..."+new Date());	
			}
		}, 0,seconds*1000);
	}
	
	public static void main(String[] args) {
		System.out.println("main start");
		new TimerDemoTest(5).t1();
		System.out.println("main end");
	}
}
